package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"shop_srv/shopclient"
)

type ServiceContext struct {
	Config    config.Config
	AutoToken rest.Middleware
	ShopRpc   shopclient.Shop
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:    c,
		AutoToken: middleware.NewAutoTokenMiddleware().Handle,
		ShopRpc:   shopclient.NewShop(zrpc.MustNewClient(c.ShopRpc)),
	}
}
